<template>
	<view>
		<!-- 会话列表 -->
		<uni-list>
			<uni-list-item v-for="item in groupList" @click="entrychat(item)" clickable :title="item.groupName">

			</uni-list-item>
		</uni-list>



	</view>
</template>

<script>
	import {
		saveChatList
	} from "../../utils/utils"

	export default {
		data() {
			return {

				groupList: [],
			}
		},
		methods: {

			entrychat(item) {

				uni.navigateTo({
					url: "/pages/chatGroup/chatGroup?groupInfo=" + JSON.stringify(item)
				})
				saveChatList(item, 2);
			},

		},
		onReady() {

			let userId = uni.getStorageSync("login:userid");
			console.log("用户", userId)
			if (userId == null || userId == "") {
				uni.redirectTo({
					url: "/pages/login/login"
				})
				return;
			}

			let that = this;
			//加载用户列表
			uni.request({
				url: "http://localhost:9501/api/queryGroup",
				method: 'POST',
				data: {
					userId
				},
				success(res) {
					console.log(res.data);
					that.groupList = res.data.data;
				}
			})




		}
	}
</script>

<style>

</style>